package praktikumid.w02.p1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Code from 09.09.2013 (week 2, monday 0800).
 * Note: this code fails with cehckstyle. It's just a quick and dirty example.
 * @author Ago
 *
 */
public class Control {

	public static void main(String[] args) {
		int a;

		int n = 1;
		/*if (n == 1) {
			// n == 1
			printHello();
		} else if (n > 2) {
			// n == 2
			System.out.println("suurem kui kaks");
		} else {
			// n <> 1
			printNumber(n * 2 + 5);
		}*/
		
		switch (n) {
		case 1: // n == 1?
			printHello();
			break;
		case 2: // n == 2?
			System.out.println("kaks");
			break;
		default: // "else"
			printNumber(1000);
			break;
		}
		
		n = 5;
		printNumber(++n);
		printNumber(n);
		loop();
		
		try {
			String line = readLine();
			System.out.println(line);
		} catch (IOException e) {
			System.out.println("tekkis viga");
		}
		
		
	}
	
	
	public static void printHello() {
		System.out.println("Hello!");
	}
	
	public static void printNumber(int number) {
		//System.out.print("number: ");
		//System.out.println(number);
		System.out.println("number: " + number);
	}
	
	public static void loop() {
		int n = 10;
		
		int i = 0;
		while (i < n) {
			System.out.print(i + ", ");
			i = i + 1;
		}
		
		// infinte loop
		while (true) {
			System.out.print(i + ", ");
			i = i + 1;
			if (i > n) {
				break;
			}
		}
		
		System.out.println();
		i = 0;

		do {
			System.out.print(i + ", ");
			i = i + 1;			
		} while (i < n);
		
		System.out.println();
		
		for (i = 0; i < n; i++) { // i = i + 1
			System.out.print(i + ", ");
		}
		System.out.println();
	}
	
	public static String readLine() throws IOException {
		// IN
		// ? <-
		// buffered reader
		InputStream is = System.in;
		InputStreamReader isr = new InputStreamReader(is);
		BufferedReader br2 = new BufferedReader(isr);
		
		// br - read from console
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		

		String line = br.readLine();
		return line;
	}
}
